class Post < ActiveRecord::Base
	validates_presence_of :body, :title #1 seule ligne !
	validates_uniqueness_of :title
	validates_length_of :title, :minimum => 3
	validates_length_of :body, :minimum => 10
	has_many :comments
	belongs_to :user

	def self.search(search, page)
		paginate	:per_page => 5, :page => page,
					:condition => ['title like ?', "%#{search}%"],
					:order => 'name'
	end
end